package com.zima.mall.controller;

import com.zima.mall.service.OrderService;
import com.zima.mall.vo.TableVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    OrderService orderService;

    @RequestMapping("/findAllOrders/{page}/{size}")
    public TableVo findAllOrders(@PathVariable("page") Integer page,@PathVariable("size") Integer size){
        return orderService.findAllOrders(page,size);
    }

    @RequestMapping("/findByOrderNo/{id}")
    public TableVo findByOrderNo(@PathVariable("id") Long orderNo){
        return orderService.findByOrderNo(orderNo);
    }

    @RequestMapping("/deleteOrder/{id}")
    public int deleteOrder(@PathVariable Long id){
        return orderService.deleteOrder(id);
    }

    @RequestMapping("/findByAccount/{account}")
    public TableVo findByAccount(@PathVariable String account){
        return orderService.findByAccount(account);
    }

}
